#!/bin/bash

PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

cmd=$1
file=$(cd `dirname $2`; pwd)/$(basename $2)
cnblog_config=$APP_HOME/conf/cnblog-cli.conf
jar_path=$APP_HOME/lib/cnblog-cli.jar

java -Dconfig.file=${cnblog_config} -Dexec=${cmd} -Dblog=${file} -jar  ${jar_path}
